package edu.ccut.saturn.basecomponent.database.impl.sqlserver;

import edu.ccut.saturn.basecomponent.database.IDatabaseAttribute;

/**
 * SqlServer中所使用的字段类型,数值,时间,字符
 * 
 * @author zjh
 * 
 */
public class SqlServerAttribute implements IDatabaseAttribute {
	// 位数据类型
	public static final String BIT = "BIT";
	
	// 整数类型
	public static final String TINYINT = "TINYINT";

	public static final String SMALLINT = "SMALLINT";

	public static final String INT = "INT";

	public static final String BIGINT = "BIGINT";
	
	// 近似数据类型
	public static final String FLOAT = "FLOAT";

	public static final String REAL = "REAL";

	// DECIMAL,NUMERIC数据类型
	public static final String DECIMAL = "DECIMAL";

	public static final String NUMERIC = "NUMERIC";

	// 货币数据类型
	public static final String MONEY = "MONEY";

	public static final String SMALLMONEY = "SMALLMONEY";

	// 日期和时间数据类型
	public static final String DATETIME = "DATETIME";

	public static final String SMALLDATETIME = "SMALLDATETIME";

	// 字符数据类型
	public static final String CHAR = "CHAR";

	public static final String VARCHAR = "VARCHAR";

	public static final String TEXT = "TEXT";

	// Unicode字符数据类型
	public static final String NCHAR = "NCHAR";

	public static final String NVARCHAR = "NVARCHAR";
	
	public static final String NVARCHAR_MAX = "NVARCHAR(MAX)";

	public static final String NTEXT = "NTEXT";
	
	// 二进制字符数据类型
	public static final String BINARY = "BINARY";

	public static final String VARBINARY = "VARBINARY";
	
	public static final String VARBINARY_MAX = "VARBINARY(MAX)";

	public static final String IMAGE = "IMAGE";

	// 其他数据类型
	public static final String SQL_VARIANT = "SQL_VARIANT";

	public static final String TABLE = "TABLE";

	public static final String TIMESTAMP = "TIMESTAMP";

	public static final String UNIQUEIDENTIFIER = "UNIQUEIDENTIFIER";

	public static final String XML = "XML";

	public static final String CURSOR = "CURSOR";

	/**
	 * 是否是数字类型
	 * 
	 * @author zjh
	 * @param type
	 * @return
	 */
	public boolean isNumber(String type) {
		if (BIT.equals(type) || TINYINT.equals(type) || SMALLINT.equals(type)
				|| NUMERIC.equals(type) || INT.equals(type)
				|| BIGINT.equals(type) || FLOAT.equals(type)
				|| REAL.equals(type) || DECIMAL.equals(type)
				|| MONEY.equals(type) || SMALLMONEY.equals(type)) {
			return true;
		}
		return false;
	}

	/**
	 * 是否是大数据类型
	 * 
	 * @author zjh
	 * @param type
	 * @return boo
	 */
	public boolean isLOB(String type) {
		if (TEXT.equalsIgnoreCase(type) || NTEXT.equalsIgnoreCase(type)
				|| BINARY.equalsIgnoreCase(type)|| VARBINARY_MAX.equalsIgnoreCase(type)
				|| VARBINARY.equalsIgnoreCase(type)|| NVARCHAR_MAX.equalsIgnoreCase(type)
				|| IMAGE.equalsIgnoreCase(type)) {
			return true;
		}
		return false;
	}
}
